Skip to content

fix(Button): apply disabled styles while loading - #8412

Open
anishtsudo wants to merge 3 commits into
primer:mainfrom
anishtsudo:fix-7879-loading-button-disabled-styles
Open

anishtsudo wants to merge 3 commits into
primer:mainfrom
anishtsudo:fix-7879-loading-button-disabled-styles

Conversation

@anishtsudo

@anishtsudo anishtsudo commented Sep 11, 2026 •

Copy link
Copy Markdown

Closes #7879

Loading primary buttons already set aria-disabled and drop onClick, but CSS skipped disabled visuals whenever data-loading was true. Native disabled was the only way to get the muted primary look, which is inaccessible for form submit buttons.

This applies the existing aria-disabled styles to loading buttons. <Button variant="primary" loading> now looks like a disabled primary button, stays focusable, and does not use native disabled.

Changelog

New

Changed

  • Loading Button, IconButton, and LinkButton now use disabled visuals while remaining keyboard-focusable

Removed

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

This is a visual bug fix with no API change.

Testing & Reviewing

  • Compare Loading, Disabled, and Primary in Storybook
  • Unit tests assert loading primary matches disabled primary styles without the disabled attribute
  • Loading buttons remain focusable and do not fire onClick
  • inactive primary styling is unchanged

Apply existing aria-disabled visuals to loading buttons so a
primary submit can look non-interactive without native disabled.
@anishtsudo
anishtsudo marked this pull request as ready for review September 11, 2026 17:00
@anishtsudo
anishtsudo requested a review from a team as a code owner September 11, 2026 17:00
@changeset-bot

changeset-bot Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 285b6a6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Loading link-style buttons still show an interactive underline on hover.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Updates loading buttons to use disabled styling while remaining focusable.

Changes:

  • Applies disabled CSS to loading button variants.
  • Adds primary-loading unit and visual coverage.
  • Adds an @primer/react patch changeset.
File Description
ButtonBase.module.css Applies disabled styles to aria-disabled loading buttons.
Button.features.stories.tsx Adds a loading-primary story.
Button.docs.json Registers the new story.
Button.test.tsx Tests loading styling and interaction behavior.
Button.test.ts Adds visual regression coverage.
loading-button-disabled-styles.md Documents the patch release.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.


&:disabled,
&[aria-disabled='true']:not([data-loading='true']) {
&[aria-disabled='true'] {

@francinelucca francinelucca left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this and adding tests! have a couple change requests

Comment on lines +197 to +202
export const LoadingPrimary = () => (
<Button variant="primary" loading>
Submit
</Button>
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already have a loading story https://primer.style/react/storybook/?path=/story/components-button-features--loading, can we expand that one to show the different variants (like https://primer.style/react/storybook/?path=/story/components-button-features--disabled) instead of creating a new one? 🙏🏽

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the existing Loading story to show default, primary, danger, and invisible, same layout as Disabled. Removed the separate Loading Primary story.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what purpose are these screenshots serving? can we remove them?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed them. They were only for the PR description and were not used by tests.

Show every loading variant in the existing story, remove the review screenshots, and keep loading links from underlining on hover.
@anishtsudo

Copy link
Copy Markdown
Author

Addressed the review comments. The Loading story now shows the variants, and the screenshots are removed. Ready for another look.

This branch was successfully deployed

1 active deployment
github-pages — 285b6a6f Deployed Sep 24, 2026 by anishtsudo via deploy-preview #29729
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rendering an accessible disabled loading primary button is impossible

3 participants